package com.wydexcel.generate.process;


import com.wydexcel.generate.properties.ExcelFieldProperties;
import com.wydexcel.generate.properties.ExcelRowConfProperties;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;


import static org.apache.poi.ss.util.CellUtil.getCell;

public class WydExcelRowValueProcessImpl implements WydExcelRowValueProcess {
    private int startIndex = 0;

    public int getEndIndex() {
        return endIndex;
    }

    public void setStartIndex(int startIndex) {
        this.startIndex = startIndex;
    }

    public int getStartIndex() {
        return startIndex;
    }

    private int endIndex = 0;
    @Override
    public Row exportProcess(Row row, ExcelRowConfProperties rowConfDTO) {
        if (null == rowConfDTO || (null == rowConfDTO.getHeight())) {
            return row;
        }
        row.setHeight(rowConfDTO.getHeight());
        return row;
    }

    @Override
    public void exportCellProcess(String value, ExcelFieldProperties excelFieldProperties, Row bodyRow) {
        //生成body
        if (null == value || "".equals(value.trim())) {
            return;
        }
        Cell cell = getCell(bodyRow, excelFieldProperties.getExcelStartCellIndex());
        cell.setCellValue(value);

    }
}
